<?php
require_once('tpl/head.php');
include_once('./system/dbConn.php');
connect();
$vid=$_GET["vid"];
$sql="select * from videos where vid=$vid";
$result=mysql_query($sql);//结果集
$row=mysql_fetch_assoc($result);//取结果集中的数据

//上传人查询
$adminid=$row['uploadadmin'];
$sqlname="select adminname from admins where adminid=$adminid";
$resultname=mysql_fetch_assoc(mysql_query($sqlname));

//点击量
$hittime=$row['hittimes']+1;
$sqladd="update videos set hittimes=$hittime where vid=$vid";
$resulttime=mysql_query($sqladd);
?>


<div class="container">

    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-12">


            <div class="row box">
                <div class="col-lg-4 text-center">
                   <!-- <img src="posters/<?php echo $row["pic"]; ?>" class="responsive img-thumbnail"/> -->
                   <video width="100%" height="345px" controls="controls" poster="./posters/<?php echo $row["pic"];?>">
                        <source src="<?php echo $row["address"];?>" type="video/mp4">  <!-- 视频地址 视频格式 -->
                   <video>

                    
                    <p><?php echo $row["videoname"]; ?></p>

                </div><!--放视频海报和标题-->
                <div class="col-lg-8 text-center">
                    <table class="table table-striped">    <!-- table>tr*7>td*2 -->
                    <tr>
                        <td>专栏</td>
                        <td><?php  
                        $tid=$row["tid"];
                        $sql0="select * from videotype where tid=$tid";
                        $result0=mysql_query($sql0);
                        $row2=mysql_fetch_assoc($result0);
                        echo $row2["typename"];
                         ?></td>
                    </tr>
                    <tr>
                        <td>上传时间</td>
                        <td><?php echo $row["uploaddate"]; ?></td>
                    </tr>
                    <tr>
                        <td>点击次数</td>
                        <td><?php echo $hittime; ?></td>
                    </tr>
                    <tr>
                        <td>上传人</td>
                        <td><?php echo $resultname["adminname"]; ?></td>
                    </tr>
                    <tr>
                        <td>下载次数</td>
                        <td><?php echo $row["downtimes"]; ?></td>
                    </tr>
                    <tr>
                        <td>有事找站长</td>
                        <td><a href="mailto:zhoaguomin15@nou.com.cn">意见箱</a></td>
                    </tr>
                    <tr>
                        <td>下载地址</td>
                        <td><a href="">点击这里下载</a></td>
                    </tr>
                    </table>

                </div><!--表格显示视频详细信息-->


            </div>
            <!--/row-->
            <div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">内容简介

                    </h2>
                    <?php 
                    echo $row["intro"];

                     ?>

                </div>
            </div>  <!--/row-->

            <div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">留言列表

                    </h2>
                    <?php 
                    $sqlc="select * from comments where vid=$vid";
                    $resultc=mysql_query($sqlc);
                     ?>
                    <table class="table table-striped">
                        <tr>
                            <th>编号</th>
                            <th>留言内容</th>
                            <th>留言时间</th>
                            <th>留言人</th>
                        </tr>
                    <?php 
                    while ($rowc=mysql_fetch_assoc($resultc)) {
                        # code...
                        ?>
                        <tr>
                            <td><?php echo $rowc["cid"]; ?></td>
                            <td><?php echo $rowc["content"]; ?></td>
                            <td><?php echo $rowc["cdate"]; ?></td>
                            <td><?php 
                                $uid=$rowc["uid"];
                                $sqluname="select uname from users where uid=$uid";
                                $resultuname=mysql_query($sqluname);
                                $rowuname=mysql_fetch_assoc($resultuname);
                                echo $rowuname["uname"]; 
                                ?></td>
                        </tr>
                    <?php
                    }
                     ?>
                    </table>
                    </div>
            </div>  <!--/row-->


            <div class="row box">

                <div class="col-lg-12">
                    <h2 class="intro-text text-center">您的留言

                    </h2>
                    <form class="form-horizontal" action="doCommentAdd.php" method="post">
                        
                        <input type="hidden" name="vid" value="<?php echo $vid; ?>">

              <div class="form-group">
                <div class="col-sm-12">
                  <div class="checkbox">
                    <?php 
                    if(isset($_SESSION['username'])){
                     ?>
                   <textarea class="form-control" rows="3" name="content"></textarea>
                   <?php
                        }
                        else{
                            echo "请先<a href='#'' data-toggle='modal' data-target='#login'>登录</a>后留言";
                            }
                    ?>
              </div>
          </div>
      </div>
      <?php
         if(isset($_SESSION['username'])){
        ?>
      <div class="form-group">
        <div class="col-sm-12">
          <button type="submit" class="btn btn-default">发表留言</button>
      </div>
  </div>
   <?php 
    } 
    ?>
</form>
                </div>
            </div>  <!--/row-->



        </div>
        <!--/.col-xs-12.col-sm-12-->

       
    </div>
    <!--/row-->

    

</div>
<!--/.container-->
<?php
require_once('tpl/foot.php');
include_once('./system/dbConn.php');
?>


<!-- //show.php页面中的第一行里的typename和adminname要取到值，并输出；
//根据用户是否登录，来显示第四行中的内容，如果用户登录成功，第四行显示
//发表留言的表单，如果用户未登录，显示一句话：请登录后留言（其中，登录做成超链接） -->